package socket;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author 杜伟毅
 * @version 1.0
 * @since 2024/09/25
 * socket网络编程
 */
public class SocketTest {
    @Test
    public void inetAddressTest() throws UnknownHostException {
        InetAddress address=InetAddress.getLoopbackAddress();
        System.out.println(address);
        InetAddress[] allAddress = InetAddress.getAllByName("www.baidu.com");
        for (InetAddress inetAddress : allAddress) {
            System.out.println(inetAddress);
        }

        InetAddress[] allByName = InetAddress.getAllByName("LAPTOP-NK0JKQB6");
        System.out.println(Arrays.toString(allByName));

        byte[] bytes={127,0,0,1};
        InetAddress byAddress = InetAddress.getByAddress(bytes);
        System.out.println(byAddress);

    }
}
